<?php

class Shell_Command_Man extends Shell_Command_Abstract_CommandBase implements Shell_Command_Abstract_IShellCommand{
//*************************************************************************************************
		public function __construct() 
		{
			parent::__construct();
			$this->NAME = "man";
		}
		
//*************************************************************************************************
		public function execute($arguments) 
		{
			$helpPath = getcwd() . "/shell/data/";
			
			// if no arguments provided, display the generic help
			if ( count($arguments)==0 )
			{
				if ($helpText = @file_get_contents($helpPath.'man.txt') )
					echo $helpText . "\n\n";
				else
					echo "\nHelp: no help file found!\n\n";
				
				return ;
			}
			
			// try to display a specific help file
			$topic = $arguments[count($arguments)-1];
			
			if ($helpText = @file_get_contents($helpPath.'man_'.$topic.'.txt') )
				echo $helpText . "\n\n";
			else
				echo "\nHelp: no help for $topic found!\n\n";
			
		}
		
//*************************************************************************************************		
		public function __toString() {
			return "[Help]";
		}
}